﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using App.Utilities.Web.Handlers;
using CRMBiz;
using Newtonsoft.Json;

namespace CRMWeb.WebServices
{
    /// <summary>
    /// Summary description for BindLastResultForClientPro
    /// </summary>
    public class BindLastResultForClientPro : BaseHandler
    {

        public override void OnMethodInvoke(OnMethodInvokeArgs e)
        {
            context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            context.Response.Cache.SetExpires(DateTime.MinValue);
            context.Response.Cache.SetNoStore();

            //e.Cancel = true;

            SetResponseContentType(ResponseContentTypes.HTML);
        }

        public override void AfterMethodInvoke(object result)
        {
            base.AfterMethodInvoke(result);
        }

        public void LastResultData()
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(ClientProfileHandler.BindLastResultForClientProfile());
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void OutSrcLender()
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(ClientProfileHandler.BindOutSourceLender());
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public void ReferrerData()
        {
            try
            {
                string strJson = JsonConvert.SerializeObject(ClientProfileHandler.BindReferrerData());
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }

        //public bool IsReusable
        //{
        //    get
        //    {
        //        return false;
        //    }
        //}
    }
}